package app.kotlin_1.adapter

import android.content.Context
import android.support.v7.widget.RecyclerView
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import app.kotlin_1.R
import app.kotlin_1.utils.inflate

/**
 * Created by 刘智强 on 2017/9/19.
 */
class HomeGameKindAdapter() : RecyclerView.Adapter<HomeGameKindAdapter.ItemViewHolder>() {
    private var context: Context? = null;
    private var kindList: MutableList<String>? = null

    constructor(context: Context?, kindList: MutableList<String>?) : this() {
        this.context = context
        this.kindList = kindList
    }

    override fun onBindViewHolder(holder: ItemViewHolder?, position: Int) {
        holder?.tv_kind_name?.setText(kindList?.get(position))

    }

    override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): ItemViewHolder {
//        return ItemViewHolder(LayoutInflater.from(context!!).inflate(R.layout.item_home_game_kind, parent,false))
    return  ItemViewHolder(parent?.inflate(R.layout.item_home_game_kind))
    }


    override fun getItemCount()=kindList?.size!!


    inner class ItemViewHolder : RecyclerView.ViewHolder {

     var tv_kind_name: TextView

        constructor(itemView: View?) : super(itemView) {
            tv_kind_name = itemView?.findViewById(R.id.tv_kind_name) as TextView

        }
    }
}